<template>
	<view class="pages_intelligence" :style="{paddingTop: `${search.height+search.top+10}px`}">
		<myTabs :title="title" @goBlack="goBlack" :mybackgroundColor="'#fff'"></myTabs>
		<image :style="{top: `${0}px`}" mode="widthFix" class="assessHeardImg" src="/static/img/trademarkBg.png">
		</image>
		<!-- <view v-if="assessObj" :style="{top: `${search.height+search.top+10}px`}" class="assess_heardBox">
			<p>选址及定价</p>
			<p>- 数据更新至：{{assessObj.month | ff_month}} -</p>
		</view> -->
		<view v-if="assessObj && isLoading==2" :style="{top: `${search.height+search.top+30}px`}" class="assessBoxBig">

			<view class="analyse_catalog_box">
				<view class="analyse_catalog_boxliner">
					<!-- <image class="analyse_catalog_boxlinerImg" src="/static/img/locationBg.png"></image> -->
					<!-- 	<view class="analyse_catalog_boxlinerHeard">
						<span>广州最优开店位置</span>
						<span>TOP5</span>
					</view> -->
					<view class="pages_intelligenceHeard">
						<view class="pages_intelligenceHeardLeft">
							<span>{{location.name}}最优开店位置</span>
							<span>TOP{{assessObj.length}}</span>
						</view>
						<view class="pages_informationHeardrIGHT">
							<!-- 					<span>更多资讯</span>
										<image src="/static/img/rightIcon.png"></image> -->
						</view>
					</view>
					<view class="analyse_catalog_boxlinerTitle">
						<span>排名</span>
						<span>开店位置</span>
						<!-- <span>推荐指数</span> -->
					</view>
					<view class="analyse_catalog_boxlinerBody">
						<view
						   @click="siteTopIndex=index"
							:class="index%2==0 ? 'analyse_catalog_boxlinerBodyItems whitexx' : 'analyse_catalog_boxlinerBodyItems darkcolor'"
							v-for="(item,index) in assessObj" :key="index">
							<span>
								<!-- {{item.sort}} -->
								NO.{{index+1}}
							</span>
							<span :class="siteTopIndex==index ? 'analyse_catalog_boxlinerBodyItems_acr' : ''">
								{{item.siteName}}
							</span>
							<!-- <image src="/static/img/leftActionIcon.png"></image> -->
							<!-- <span>{{item.recommendIndex}}</span> -->
						</view>
					</view>

				</view>
			</view>

			<!-- 地址选择 -->
			<!-- <view class="assessBox_siteBox">
				<span @click="siteTopIndex=index" v-for="(item,index) in assessObj" :key="index"
					:class="index==siteTopIndex ? 'assessBox_siteBoxItems assessBox_siteBoxItems-act' : 'assessBox_siteBoxItems'">{{item.siteName}}</span>
			</view> -->



			<view class="assessBox_statusBox">
				<view class="assessBox_statusBoxItems">
					<view class="assessBox_statusBoxItemsTop">
						<view>
							<span>竞争门店数</span>
						</view>
						<image src="/static/img/pricingShop.png"></image>
					</view>
					<view class="assessBox_statusBoxItemsBotton">
						<span>{{assessObj[siteTopIndex].competeNum.toLocaleString()}}</span>
						<!-- <span v-show="assessObj.competeNumChange" :class="assessObj.competeNumChange>0 ? 'red' : assessObj.competeNumChange<0 ? 'green' : ''">{{assessObj.competeNumChange>0 ? `+${assessObj.competeNumChange}` : assessObj.competeNumChange}}</span> -->
					</view>
				</view>
				<view class="assessBox_statusBoxItems">
					<view class="assessBox_statusBoxItemsTop">
						<view>
							<span>竞争门店数变化</span>
						</view>
						<image src="/static/img/pricingRen.png"></image>
					</view>
					<view class="assessBox_statusBoxItemsBotton">
						<span v-show="assessObj[siteTopIndex].competeNumChange"
							:class="Number(assessObj[siteTopIndex].competeNumChange)>0 ? 'red' : Number(assessObj[siteTopIndex].competeNumChange)<0 ? 'green' : ''">{{assessObj[siteTopIndex].competeNumChange>0 ? `+${assessObj[siteTopIndex].competeNumChange}` : assessObj[siteTopIndex].competeNumChange}}</span>
					</view>
				</view>
				<view class="assessBox_statusBoxItems">
					<view class="assessBox_statusBoxItemsTop"  @click.stop="modalTast(0)">
						<view>
							<span>满意度</span>
						</view>
						<image src="/static/img/markIcon.png"></image>
					</view>
					<view class="assessBox_statusBoxItemsBotton">
						<!-- <span>{{assessObj.recommendNum}}</span> -->
						<span>{{assessObj[siteTopIndex].recommendNum}}</span>
					</view>
				</view>
				<view class="assessBox_statusBoxItems">
					<view class="assessBox_statusBoxItemsTop"  @click.stop="modalTast(1)">
						<view>
							<image src="/static/img/pricingWx.png"></image>
							<span>满意度变化</span>
						</view>

						<image src="/static/img/markIcon.png"></image>
					</view>
					<view class="assessBox_statusBoxItemsBotton">
						<!-- <span>{{assessObj.satisNum}}</span> -->
						<span v-show="assessObj[siteTopIndex].recommendNumChange"
							:class="Number(assessObj[siteTopIndex].recommendNumChange)>0 ? 'red' : Number(assessObj[siteTopIndex].recommendNumChange)<0 ? 'green' : ''">{{assessObj[siteTopIndex].recommendNumChange>0 ? `+${assessObj[siteTopIndex].recommendNumChange}` : assessObj[siteTopIndex].recommendNumChange}}</span>
					</view>
				</view>
			</view>

			<!-- <view class="cuisinePricingBox">
				<view class="pages_intelligenceHeard">
					<view class="pages_intelligenceHeardLeft">菜品定价推荐</view>
				</view>
				
				<view class="cuisinePricingBox_main">
					<view class="cuisinePricingBox_mainItemss" @click="goXiaoChen" v-for="(item,index) in assessObj[siteTopIndex].siteStoreList" :key="index">
							   <view class="cuisinePricingBox_mainItemsImgBox">
									<image mode="aspectFill" :src="item.avatar">
								</view>
								<view class="cuisinePricingBox_mainItemsImgBoxRight">
									<view  class="cuisinePricingBox_mainItemsImgBoxRightName">{{item.name}}</view>
									<view class="cuisinePricingBox_mainItemsImgBoxRightBottonBox">
										<view class="cuisinePricingBox_mainItemsImgBoxRightTops">
											<span>门店数量：{{item.num}}</span>
											<span>推荐指数：{{item.recommend}}</span>
										</view>
										<view class="cuisinePricingBox_mainItemsImgBoxRightTops">
											<span>人均消费：¥{{item.consume}}</span>
											<span>满意度指数：{{item.satis}}</span>
										</view>
									</view>
								</view>
					</view>
				</view>
			</view> -->

			<view class="cuisinePricingBox">
				<view class="pages_intelligenceHeard">
					<view class="pages_intelligenceHeardLeft">推荐客单定价</view>
				</view>
				<view class="cuisinePricingBox_mainItems_text">{{assessObj[siteTopIndex].spreadPriceRecommendDesc}}</view>
				<view class="cuisinePricingBox_main">
					<view class="cuisinePricingBox_mainItems" v-for="(item,index) in ff_sort(assessObj[siteTopIndex].sitePriceList)">
						<view>{{item.priceDesc}}</view>
						<view>
							<u-line-progress :showText="false" :percentage="ff_ratio(item.ratio)" height="8"
								activeColor="#FFDA2D"></u-line-progress>
						</view>
					</view>
				</view>

			</view>


			<p class="pages_end">- 章鱼小数据·版权所有 -</p>

		</view>
		<view v-else class="kong">
			<load v-if="isLoading==1" @updataIsLoading="updataIsLoading" :isLoading="isLoading"></load>
			<empty v-else-if="isLoading==0" ></empty>
		</view>
		<!-- {{tastText}} -->
		<u-modal  @confirm="ff_confirm" :show="modalShow" :title="modalTitle" confirmText="我确定了"></u-modal>



	</view>

</template>

<script>
	import myTabs from "@/components/myTabs/index.vue"
	import load from "@/components/load/index.vue"
	import empty from "@/components/empty/index.vue"
	
	export default {
		components: {
			empty,
			load,
			myTabs,
			
		},
		data() {
			return {
				isLoading: 1,
				siteTopIndex: 0,
				modalShow: false,
				modalTitle: '',
				title: '选址及定价',
				assessObj: null,
				bgColor: 'transparent',
				tastText: '加载中'
			}
		},
		onLoad() {
			// #ifndef H5
			let search = uni.getMenuButtonBoundingClientRect()
			this.$store.commit('updataSearch', search);
			// #endif
			this.init();
			
		},
		onPageScroll(e) {
			console.log('e.scrollTop', e.scrollTop)
			this.bgColor = e.scrollTop == 0 ? 'transparent' : '#ffe053';
		},
		computed: {
			search() {
				return this.$store.state.search;
			},
			location() {
				return this.$store.state.location;
			},

		},
		filters: {
			ff_month(val) {
				let year = new Date(val).getFullYear();
				let moth = new Date(val).getMonth() + 1 < 10 ? `0${new Date(val).getMonth()+1}` : new Date(val)
					.getMonth() + 1;
				let day = new Date(val).getDay() + 1 < 10 ? `0${new Date(val).getDay()+1}` : new Date(val).getDay() + 1;
				return `${year}年${moth}月${day}日`
			}
		},
		methods: {
			ff_sort(arr) {
				return this.$Tools.rank(arr);
			},
			ff_ratio(val){
				let nowVal = val*100;
				return nowVal
			},
			updataIsLoading(index){
				if(index==2){
					this.isLoading = this.assessObj ? index : 0;
				}
			},
			modalTast(index){
				this.modalTitle = index==0?'代表消费后的满意程度，分数越高热度越高':index==1?'代表消费后的满意度变化，数值越高热度越高':'';
				this.modalShow = true;
			},
			ff_confirm(){
				this.modalShow = false;
			},
			//调用预览图片的方法
			ff_previewImage(myImgs, index = 0) {
				uni.previewImage({
					urls: [myImgs],
					current: index
				})
			},
			init() {
				// uni.showLoading({
				// 	title: '加载中',
				// 	mask: true
				// })
				let location = uni.getStorageSync('location');
				let variety = uni.getStorageSync('variety');
				let req = {
					cityId: location.id,
					categoryId: variety.children[0].id
				}
				this.$api.analysisBusinessGetSite(req).then(res => {
					if (res.code == 200) {
						uni.hideLoading();
						this.assessObj = res.data;
						this.isLoading=1;
					} else if (res.code == 504) {
						uni.showToast({
							icon: 'none',
							mask: true,
							title: res.msg
						})
						setTimeout(() => {
							uni.redirectTo({
								url: '/package/marketing/index'
							})
						}, 1000)
					} else {
						this.isLoading=1;
						uni.hideLoading();
						this.assessObj = null;
						this.tastText = "暂无内容"
					}
				})
			},
			goBlack() {
				uni.navigateBack();
			},
			goXiaoChen() {
				uni.navigateToMiniProgram({
					appId: 'wx734c1ad7b3562129',
					path: 'pages/webview/webview?url=https%3A%2F%2Fm.dianping.com%2Fshop%2Fk1XpjuV2LJnmoPwL%2Fdishlist%3Fmsource%3Dwxappmain',
					success(res) {
						// 打开成功
						console.log('跳转成功---->', res)
					}
				});
			},
		}
	}
</script>
<style lang="scss" scoped>
	.pages_intelligence {
		background-color: #F0F0F0;
		height: 100vh;
		box-sizing: border-box;
		overflow: scroll;
		position: relative;

		.assessBoxBig {
			left: 50%;
			transform: translateX(-50%);
			position: absolute;
			width: 686rpx;
		}

		.assessBox_statusBoxItems {
			width: 308rpx;
			height: 154rpx;
			border-radius: 16rpx;
			padding: 16rpx;
			box-sizing: border-box;
			background-color: #F7F7F7;
			display: flex;
			flex-direction: column;
			justify-content: space-around;
			align-items: self-end;

		}

		.pages_end {
			padding: 32rpx 0 48rpx 0;
			text-align: center;
			font-size: 24rpx;
			font-family: 蘋方-簡;
			font-weight: normal;
			color: #CCCCCC;
		}


		.assessBox_statusBoxItems:nth-child(3) {
			margin-top: 24rpx;
		}

		.assessBox_statusBoxItems:nth-child(4) {
			margin-top: 24rpx;
		}

		.assessBox_statusBoxItemsTop {
			display: flex;
			width: 100%;
			justify-content: space-between;

			view {
				display: flex;
				align-items: center;
				
			}

			span {
				display: inline-block;
				height: 34rpx;
				font-size: 24rpx;
				font-family: PingFang SC;
				font-weight: 400;
				line-height: 34rpx;
				color: #333333;
				margin-left: 4rpx;

			}

			image {
				width: 32rpx;
				height: 32rpx;
			}
		}

		.assessHeardImg {
			position: absolute;
			width: 100%;
		}

		.pages_intelligenceHeard {
			display: flex;
			justify-content: space-between;
			box-sizing: border-box;
		}

		.cuisinePricingBox_mainItemss {
			display: flex;
			padding-bottom: 24rpx;
		}

		.cuisinePricingBox_mainItemsImgBox {
			width: 144rpx;
			height: 144rpx;
			margin-right: 24rpx;
			border-radius: 16rpx;
			flex: 0 0 144rpx;
			overflow: hidden;

			image {
				width: 100%;
				height: 100%;
			}
		}

		.cuisinePricingBox_mainItemsImgBoxRight {
			flex: 1;

		}
	

		.cuisinePricingBox_mainItemsImgBoxRightName {
			height: 40rpx;
			font-size: 28rpx;
			font-family: PingFang SC;
			font-weight: bold;
			line-height: 40rpx;
			color: #333333;
		}

		.cuisinePricingBox_mainItemsImgBoxRightBottonBox {
			display: flex;
		}

		.cuisinePricingBox_mainItemsImgBoxRightTops {
			flex: 1;

			span {
				display: inline-block;
				height: 34rpx;
				font-size: 24rpx;
				font-family: PingFang SC;
				font-weight: 400;
				line-height: 34rpx;
				color: #999999;
			}
		}

		.cuisinePricingBox_main {
			margin-top: 32rpx;

		}

		.pages_intelligenceHeardLeft {
			// border-left: 8rpx solid #FFDA2D;
			height: 40rpx;
			font-size: 28rpx;
			font-family: 蘋方-簡;
			font-weight: bold;
			line-height: 40rpx;
			color: #333333;
			position: relative;
			padding-left: 16rpx;

			&::after {
				content: "";
				width: 8rpx;
				height: 28rpx;
				position: absolute;
				left: 0;
				top: 50%;
				transform: translateY(-50%);
				background: #FFDA2D;

			}

			span:nth-child(2) {
				color: #FF9E00;
			}
		}

		.cuisinePricingBox_mainItems_text {
			height: 34rpx;
			margin-top: 8rpx;
			font-size: 24rpx;
			font-family: PingFang SC;
			font-weight: 400;
			line-height: 34rpx;
			color: #999999;
		}

		.cuisinePricingBox_mainitesText {
			height: 38rpx;
			font-size: 26rpx;
			font-family: PingFang SC;
			font-weight: bold;
			line-height: 38rpx;
			color: #000000;
			text-align: center;
			flex: 1;
		}

		.cuisinePricingBox_mainitesImg {
			width: 122rpx;
			height: 122rpx;
			border-radius: 24rpx;

			image {
				width: 100%;
				height: 100%;
			}
		}

		.cuisinePricingBox_mainites {
			display: inline-block;
			width: 310rpx;
			height: 122rpx;
			display: flex;
			background: #f7f7f7;
			border-radius: 24rpx;
			align-items: center;
			margin-top: 16rpx;
		}

		.cuisineBox_heardTwoMain {
			margin-top: 16rpx;

			span {
				display: inline-block;
				height: 42rpx;
				line-height: 42rpx;
				text-align: center;
				padding: 0 12rpx;
				border-radius: 10rpx;
				background-color: #FFDA2D;
				margin-right: 16rpx;
				margin-bottom: 16rpx;
				font-size: 24rpx;
				font-family: PingFang SC;
				font-weight: bold;

			}
		}

		.cuisinePricingBox_mainItems {
			display: flex;

			view:nth-child(1) {
				flex: 0 0 110rpx;
				height: 34rpx;
				font-size: 24rpx;
				font-family: PingFang SC;
				font-weight: 400;
				line-height: 34rpx;
				color: #999999;
				margin-right: 16rpx;
				margin-bottom: 16rpx;
				text-overflow: ellipsis;
				overflow: hidden;
				white-space: normal;
			}

			view:nth-child(2) {
				flex: 1;
				height: 34rpx;
				display: flex;
				align-items: center;
			}

		}
		/deep/.u-modal__title{
			color: #333 !important;
			    text-align: center;
			    padding-top: 25px;
			    padding: 25px 70rpx 0 70rpx !important;
				font-weight: 550 !important;
		}
		/deep/.u-modal__button-group__wrapper__text{
			    color: #556994 !important;
		}

		.analyse_catalog_box {
			width: 100%;
			border-radius: 24rpx;
			padding: 24rpx;
			background-color: #fff;
			box-sizing: border-box;
			position: relative;
			margin-bottom: 24rpx;
		}

		.analyse_catalog_boxliner {
			// padding: 16rpx;
			border-radius: 16rpx;
			// background-color: #F7F7F7;
			position: relative;
		}

		.analyse_catalog_boxlinerImg {
			position: absolute;
			top: 0;
			right: 0;
			width: 120rpx;
			height: 120rpx;
		}

		.analyse_catalog_boxlinerTitle {
			padding: 24rpx 0 8rpx;
			display: flex;

			span {
				flex: 0 0 142rpx;
				display: inline-block;
				height: 34rpx;
				font-size: 24rpx;
				font-family: PingFang SC;
				font-weight: 400;
				line-height: 34rpx;
				color: #999999;
				text-align: center;
			}

			span:nth-child(2) {
				flex: 1
			}
		}

		.whitexx {
			background-color: #F7F7F7;
		}

		.darkcolor {
			background: #ECECEC;
			border-top: 2rpx solid transparent;
			border-bottom: 2rpx solid transparent;
			box-sizing: border-box;
		}

		.analyse_catalog_boxlinerBodyItems {
			padding: 16rpx 0;
			display: flex;
			align-items: center;
			span {
				flex: 0 0 142rpx;
				display: inline-block;
				height: 34rpx;
				font-family: PingFang SC;
				font-weight: 400;
				line-height: 34rpx;
				color: #999999;
				font-size: 26rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #333333;
				text-align: center;
			}

			&>span:nth-child(1) {
				border-right: 2rpx solid #ddd;
			}

			span:nth-child(2) {
				    flex: 1;
				    /* display: block; */
				    position: relative;
				    white-space: nowrap;
				    overflow: hidden;
				    text-overflow: ellipsis;
				    padding: 0 20rpx;
				    box-sizing: border-box;
				    height: 52rpx;
				    background: #fff;
				    line-height: 52rpx;
				    // opacity: 0.59;
				    border-radius: 8rpx;
				    margin: 0 32rpx;
				    /* font-size: 13px; */
				    font-family: PingFang SC;
				    line-height: 52rpx;
				    color: #333333 !important;
					font-weight: bold;
				
				}
			image{
				width: 24rpx;
				height: 24rpx;
				margin-right: 20rpx;
			}
		}
		.analyse_catalog_boxlinerBodyItems_acr{
			background-color: #FFDA2D !important;
			font-weight: bold;
			
		}

		.analyse_catalog_boxlinerBodyItemsImg {
			width: 24rpx;
			height: 24rpx;
			position: absolute;
			right: 24rpx;
			top: calc(50% - 12rpx);
		}

		.analyse_catalog_boxlinerBody {
			border-radius: 16rpx;
			overflow: hidden;
		}

		.analyse_catalog_boxlinerHeard {
			height: 40rpx;
			font-size: 28rpx;
			font-family: 蘋方-簡;
			font-weight: normal;
			line-height: 40rpx;
			display: flex;
			justify-content: center;
			color: #333;
			margin: 16rpx 0 32rpx 0;

			span:nth-child(2) {
				color: #FF8900;

			}

		}


		.cuisinePricingBox {
			padding: 24rpx;
			padding-bottom: 0;
			border-radius: 24rpx;
			background: #fff;
			margin: 24rpx 0;
		}

		.assessBox_siteBox {
			width: 686rpx;
			border-radius: 24rpx;
			padding: 8rpx;
			box-sizing: border-box;
			background: #fff;
			margin-bottom: 24rpx;
		}

		.assessBox_siteBoxItems {
			display: inline-block;
			height: 60rpx;
			line-height: 60rpx;
			background: #fff;
			opacity: 1;
			border-radius: 16rpx;
			text-align: center;
			font-size: 28rpx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #333333;
			padding: 0 24rpx;
			margin: 0 8rpx 8rpx 0;
		}

		.assessBox_siteBoxItems-act {
			background: #FFDF13;
		}

		.assessBox_statusBox {
			background-color: #fff;
			border-radius: 24rpx;
			padding: 24rpx;
			display: flex;
			justify-content: space-between;
			align-items: space-between;
			flex-wrap: wrap;
		}

		.assess_heardBox {
			position: absolute;
			left: 0;
			width: 100%;
			margin: 68rpx 0;

			p {
				text-align: center;
			}

			p:nth-child(1) {
				height: 56rpx;
				font-size: 40rpx;
				font-family: 蘋方-簡;
				font-weight: bold;
				line-height: 56rpx;
				color: #343434;
				margin-bottom: 8rpx;
			}

			p:nth-child(2) {
				height: 40rpx;
				font-size: 28rpx;
				font-family: PingFang SC;
				font-weight: 400;
				line-height: 40rpx;
				color: #343434;
			}
		}

		.red {
			color: #FF471C !important;
		}

		.green {
			color: #3AD346 !important;
		}

		.assessBox_statusBoxItemsBotton {
			margin-top: 16rpx;
			display: flex;
			// justify-content: space-around;
			align-items: center;

			span {
				display: inline-block;
				height: 44rpx;
				font-size: 36rpx;
				font-family: DIN;
				font-weight: bold;
				line-height: 44rpx;
				color: #333333;
			}
		}

		.kong {
			width: 100%;
			height: 100%;
			// position: fixed;
			// top: 50%;
			// font-size: 46rpx;
			// text-align: center;
			// width: 100%;
			// color: #999;
		}

	}
</style>
